package ${packageName};

import java.util.List;
import java.util.Date;

<#list importPackage as imp>
import ${imp};
</#list>
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**   
 * Create by apisdk 
 */
@RestController
@RequestMapping(value="${basePath?uncap_first}")
public class ${className?cap_first} {
<#list services as service>
	@Autowired
	private ${service?cap_first} ${service?uncap_first};
</#list>

	@Autowired
	private ${modelName?cap_first}Service ${modelName?uncap_first}Service;

	/**
	* @description create model
	* @return
	*/
	@RequestMapping(value= "", method = RequestMethod.POST)
	public ${modelName?cap_first}Vo create${modelName?cap_first}(@RequestBody ${modelName?cap_first}Vo ${modelName?uncap_first}Vo) throws Exception {
		return ${modelName?uncap_first}Service.create${modelName?cap_first}(${modelName?uncap_first}Vo);
	}

	/**
	* @description get model through id
	* @return
	*/
	@RequestMapping(value= "/{id}", method = RequestMethod.GET)
	public ${modelName?cap_first}Vo get${modelName?cap_first}ById(@PathVariable String id){
		return ${modelName?uncap_first}Service.get${modelName?cap_first}ById(id);
	}

	/**
	* @description get model through id
	* @return
	*/
	@RequestMapping(value= "", method = RequestMethod.GET)
	public ${modelName?cap_first}Vo get${modelName?cap_first}ByExample(@PathVariable String id){
		return ${modelName?uncap_first}Service.get${modelName?cap_first}ById(id);
	}

	/**
	* @description update model through id
	* @return
	*/
	@RequestMapping(value= "/{id}", method = RequestMethod.PUT)
	public ${modelName?cap_first}Vo update${modelName?cap_first}ById(@PathVariable String id,@RequestBody ${modelName?cap_first}Vo ${modelName?uncap_first}Vo){
		return ${modelName?uncap_first}Service.update${modelName?cap_first}ById(id,${modelName?uncap_first}Vo);
	}

	/**
	* @description delete model through id
	* @return
	*/
	@RequestMapping(value= "/{id}", method = RequestMethod.DELETE)
	public void delete${modelName?cap_first}ById(@PathVariable String id){
		${modelName?uncap_first}Service.delete${modelName?cap_first}ById(id);
		return;
	}

<#if methods??>
	<#list methods as po> 
	/**
	 * @description ${po.description!}
<#list po.parameters as sdkparam>
	 * @param ${sdkparam.name}
</#list>
	 * @return
	 */
	@RequestMapping(value= "${po.reqUrl}", method = RequestMethod.${po.verb})
	public <#if po.response.collection == true>List<${po.response.type}><#else>${po.response.type}</#if> ${po.methodName}(<#list po.parameters as sdkparam><#if sdkparam.source == 'Path'>@PathVariable <#elseif sdkparam.source == 'Body'>@RequestBody() <#else></#if><#if sdkparam.collection>List<${sdkparam.type}> ${sdkparam.name}<#else>${sdkparam.type} ${sdkparam.name}</#if><#if sdkparam_has_next>, </#if></#list>){
		<#if po.response.type == 'void'>
		${po.serviceName}.${po.methodName}(<#list po.parameters as sdkparam>${sdkparam.name}<#if sdkparam_has_next>, </#if></#list>);
		<#else>
		return ${po.serviceName}.${po.methodName}(<#list po.parameters as sdkparam>${sdkparam.name}<#if sdkparam_has_next>, </#if></#list>);
		</#if>
	}
	
	</#list>
	<#else>
</#if>
}
